package jj.dao;

import static org.springframework.data.document.mongodb.query.Criteria.where;

import javax.annotation.Resource;

import jj.vo.CityFlightsVo;

import org.springframework.data.document.mongodb.MongoTemplate;
import org.springframework.data.document.mongodb.query.Query;
import org.springframework.stereotype.Repository;

@Repository
public class FlightDaoImpl {

	@Resource(name="mongoTemplate")
	private MongoTemplate mongoTemplate;
	

	public void insertCityFlights(CityFlightsVo data){
		mongoTemplate.insert(data);
	}
	
	public CityFlightsVo getCityFlights(String date, String city){
		Query q = new Query( where("date").is(date).where("city").is(city) );
		return  mongoTemplate.findOne(q, CityFlightsVo.class );
	}
}
